// lodash/fp 提供的函数式编程模块，提供了不可变auto-curried iteratee-first data-last的方法
// lodash是数据优先，函数置后；lodash/fp是函数优先，数据置后

const _ = require('lodash')
const fp = require('lodash/fp')

// lodash方法
const r1 = _.map(['a', 'b', 'c'], _.toUpper)

// lodash/fp方法
const r2 = fp.map(fp.toUpper, ['a', 'b', 'c'])
const r3 = fp.map(fp.toUpper)(['a', 'b', 'c'])

console.log(r1)
console.log(r2)
console.log(r3)

const r4 = fp.flowRight(fp.join('-'), fp.map(fp.toUpper), fp.split(' '))
console.log(r4('hello my world'))

// _和fp map方法的区别

// _.map中parseInt接受三个参数，value, index/key, collection
// parseInt('23', 0, ['23', '8', '10'])
// parseInt('8', 1, ['23', '8', '10'])
// parseInt('10', 2, ['23', '8', '10'])
console.log(_.map(['23', '8', '10'], parseInt))
console.log(fp.map(parseInt, ['23', '8', '10']))
